package com.atguigu.spzx.manager.controller;

import com.atguigu.spzx.manager.service.SysUserRoleService;
import com.atguigu.spzx.model.vo.common.Result;
import com.atguigu.spzx.model.vo.common.ResultCodeEnum;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author syh
 * @create 2023-08-18 17:59
 */
@Tag(name = "用户角色模块")
@RestController
@RequestMapping("/admin/system/userRole")
public class SysUserRoleController {
    @Resource
    SysUserRoleService userRoleService;
    // url?userId=1&roleIds=1,2,3,4,5,6
    //url?roleIds=1&roleIds=2
    @Operation(summary = "分配权限")
    @PutMapping("assignRoles")
    public Result assignRoles(Long userId , @RequestParam(value = "roleIds",required = false) List<Long> roleIds){
        userRoleService.assignRoles(userId,roleIds);
        return Result.build(null, ResultCodeEnum.SUCCESS);
    }
}
